home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / Booting Gallery / Booting Gallery (source) / Sources / Sprite Sources / SpriteGame.h < prev   
Encoding:
C/C++ Source or Header  |  1996-06-22  |  1.6 KB  |  82 lines  |  [TEXT/BROW]

  1. #pragma once
  2.  
  3. #include "Sprite.h"
  4.  
  5. #ifndef NEW
  6. #define NEW new
  7. #endif
  8. #include <DArray.h>
  9.  
  10.  
  11. class SoundManager;
  12. class CSpriteGame
  13. {
  14. public:
  15.                             CSpriteGame(short imageID);
  16.     virtual                 ~CSpriteGame();
  17.     
  18.     virtual    OSErr            Initialize();
  19.      
  20.             OSErr            IntroduceExtensionIcon(GWorldPtr image,RgnHandle mask);
  21.     
  22.             CStaticHeap*    GetSafeHeap()    {return fSafeHeap;}
  23.     
  24.     virtual    void            StartGame();
  25.     virtual    void            StopGame();
  26.  
  27.             // don't dispose of the GWorld and Rgn
  28.             Boolean            GetImage(short imageID,GWorldPtr& outGWorld,RgnHandle& outMask);
  29.             GWorldPtr        GetImage(short imageID);
  30.             RgnHandle        GetImageMask(short imageID);
  31.             
  32.             void            PlaySound(short sndID,Boolean loopQ = false);
  33.  
  34.             CSpriteWorld*    GetWorld()        {return fWorld;}
  35.  
  36. protected:
  37.  
  38.     enum { kHeapSize = 1024L * 1024L};
  39.  
  40.  
  41.     virtual CSprite*    MakeExtensionSprite(GWorldPtr image,RgnHandle mask) = 0;
  42.     virtual void        DrawBackground(const Rect& inBounds);
  43.             
  44. private:
  45.     struct Entry;
  46.     
  47.     OSErr    PreloadGameImages();
  48.     Entry*    LocateEntryByID(short inID);
  49.     
  50.     
  51.     struct Entry
  52.     {
  53.         short        id;
  54.         GWorldPtr    gWorld;
  55.         RgnHandle    maskRgn;
  56.     };
  57.     
  58.     DArray<Entry>        fImageList;
  59.     CSpriteWorld*        fWorld;
  60.     CMacHeap            fMacHeap;
  61.     CStaticHeap*        fSafeHeap;
  62.     SoundManager*        fSoundManager;
  63.     short                fImageID;
  64. };
  65.  
  66. class CGameSprite : public CPixMapSprite
  67. {
  68. public:
  69.     CGameSprite(CSpriteWorld* world,CSpriteGame* game,long id,GWorldPtr image,
  70.                         short startTop,short startLeft,RgnHandle mask);
  71.     virtual ~CGameSprite();
  72.     
  73.     CSpriteGame*        GetGame()        {return fGame;}
  74.     void                SetImageID(short inID);
  75.     void                PlaySound(short soundID);
  76.     
  77. private:
  78.     CSpriteGame*        fGame;
  79. };
  80.  
  81.  
  82.